package cn.topcodes.tcsf.awi.service;

import cn.topcodes.tcsf.app.domain.entity.AppUser;
import cn.topcodes.tcsf.wechat.domain.entity.WechatUser;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by Unicorn on 2017/11/7.
 */
public interface AwiService {

    /**
     * app和微信账号绑定
     * @param appUserId     app用户ID
     * @param wechatUserId  微信用户ID
     */
    @Transactional(readOnly = false, rollbackFor = Exception.class)
    void bind(Long appUserId, Long wechatUserId);

    /**
     * app和微信账号解除绑定
     * @param wechatUserId  微信用户ID
     */
    @Transactional(readOnly = false, rollbackFor = Exception.class)
    void unbindByWechatUserId(Long wechatUserId);

    /**
     * app和微信账号解除绑定
     * @param appUserId  APP用户ID
     */
    @Transactional(readOnly = false, rollbackFor = Exception.class)
    void unbindByAppUserId(Long appUserId);

    /**
     * 通过openId查找App用户
     * @param openId    微信OpenId
     * @return  App用户信息
     */
    AppUser findAppUserByOpenId(String openId);

    /**
     * 通过unionId查找App用户
     * @param unionId   微信unionId
     * @return  App用户信息
     */
    AppUser findAppUserByUnionId(String unionId);

    /**
     * 通过微信用户ID获取app用户信息
     * @param wechatUserId  微信用户ID
     * @return  app用户信息
     */
    AppUser findAppUserByWechatUserId(Long wechatUserId);

    /**
     * 通过App用户ID获取微信用户信息
     * @param appUserId  app用户ID
     * @return  微信用户信息
     */
    WechatUser findWechatUserByAppUserId(Long appUserId);
}
